package edu.tapestry.iddb.client.pages.groupIM;

import iddb.BuddyPOJO;
import iddb.GroupPOJO;
import iddb.GroupsInfo;
import iddb.PluginIdentificator;

import java.util.List;

import org.apache.tapestry5.ComponentResources;
import org.apache.tapestry5.annotations.ApplicationState;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.beaneditor.BeanModel;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.apache.tapestry5.services.BeanModelSource;

import edu.tapestry.iddb.client.webService.CommandsGenerator;
import edu.tapestry.iddb.client.webService.IDDBProxy;

public class DetailsGroupIM {

	@ApplicationState
	private IDDBProxy proxy;

	@Property
	private GroupPOJO group;

	@Inject
	private BeanModelSource beanModelSource;

	@Inject
	private ComponentResources resources;

	private BeanModel<BuddyPOJO> model;

	public Object initialize(PluginIdentificator ident, String goupname) {
		// groupsInfo = ((GroupsInfo) proxy.execute(CommandsGenerator
		//.getGroupsCmd(ident, groupname)));

		//this.group = (GroupPOJO) groupsInfo.getObject();

		return this;
	}

	void pageLoaded() {
		this.model = beanModelSource.create(BuddyPOJO.class, true, resources
				.getMessages());
		this.model.add("details", null);
	}

	public List<BuddyPOJO> getBuddies() {
		return group.getBuddies();
	}
}
